import 'package:flutter/material.dart';
import 'package:flutter_aggregate/model/plant/constants.dart';
import 'package:flutter_aggregate/router/app_routers.dart';
import 'package:get/get.dart';

class FeaturePlants extends StatelessWidget {
  const FeaturePlants({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      child: Row(
        children: [
          FeaturePlantCard(image: 'assets/plant/images/bottom_img_1.png', press: () {
            Get.toNamed('${AppRouters.plantHome}${AppRouters.plantDetail}');
          }),
          FeaturePlantCard(image: 'assets/plant/images/bottom_img_2.png', press: () {
            Get.toNamed('${AppRouters.plantHome}${AppRouters.plantDetail}');
          }),
        ],
      ),
    );
  }
}

class FeaturePlantCard extends StatelessWidget {
  const FeaturePlantCard({
    Key? key, 
    required this.image, 
    required this.press,
  }) : super(key: key);
  
  final String image;
  final VoidCallback press;

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return GestureDetector(
      onTap: press,
      child: Container(
        width: size.width * .8,
        height: 185,
        margin: const EdgeInsets.only(
          left: palntKDefaultPadding,
          top: palntKDefaultPadding / 2,
          bottom: palntKDefaultPadding / 2
        ),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          image: DecorationImage(
            fit: BoxFit.cover,
            image: AssetImage(image)
          )
        ),
      ),
    );
  }
}